(function () {
    //1.实例化对象
    var myChart = echarts.init(document.querySelector('#Half_a_year_statistics'));
//2.指定配置项和数据
    var option = {


        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                axisLabel:{
                    color:"rgba(255,255,255,0.6)",
                    fontSize: fontSize(0.12),
                },

                axisLine:{
                    show:false
                },
                //是否让线条与坐标轴有缝隙
                boundaryGap: true,

                data: ['五月', '六月', '七月', '八月', '九月', '十月', '十一月'],
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                axisLabel:{
                    color:"rgba(255,255,255,0.6)",
                    fontSize: fontSize(0.12),
                },
                splitLine:{
                    lineStyle:{
                        color:'#012f4a'
                    },

                },

            }
        ],
        series: [
            {
                name: '合计人数',
                type: 'bar',
                barWidth: '40%',
                data: [8286, 8359, 8511, 8587, 8724, 8879,8983],
                itemStyle:{
                    //修改柱型圆角
                    barBorderRadius:5
                }
            }
        ]
    };
//3.把配置项给实例对象
    myChart.setOption(option);
    //4、让图表自适应屏幕
    window.addEventListener("resize",function () {
            myChart.resize();
        }
    )
})();

function fontSize(res){
    let docEl = document.documentElement,
        clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = 100 * (clientWidth / 2080);
    return res*fontSize;
}
